package com.saikei.statstitlebar;


import android.content.Context;
import android.graphics.Color;
import android.view.ViewGroup;
import android.widget.ImageView;

public class BarImageView extends androidx.appcompat.widget.AppCompatImageView {

    public BarImageView(Context context) {
        super(context);
        setScaleType(ScaleType.CENTER);
        setLayoutParams();
    }

    @Override
    public void setImageResource(int resId) {
        super.setImageResource(resId);
    }

    @Override
    public void setScaleType(ScaleType scaleType) {
        super.setScaleType(scaleType);
    }

    public void setImageColorWithBar(int barColor){
        if (TitleUtil.getRgb(barColor)){
            setColorFilter(Color.BLACK);
        }else {
            setColorFilter(Color.WHITE);
        }
    }

    public void setLayoutParams() {
        ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        super.setLayoutParams(layoutParams);
    }
}
